<template>
    <div class="app-container">
        <div class="head">
            <img src="@/assets/img/Layout/position.png" />
            <p class="see-block">盘点单</p>
        </div>
        <div class="view-container">
            <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button
                        class="btn-success"
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="add()"
                        v-hasPermi="['system:stocktakingOrder:add']"
                    >新建</el-button>
                </el-col>
            </el-row>
            <el-table v-loading="loading" :data="list" @row-click="handleView" border>
                <el-table-column label="序号" type="index" align="center" width="50">
                    <template slot-scope="scope">
                        <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="单据编码" align="center" prop="code" width="150" />
                <el-table-column label="业务日期" align="center" prop="businessDate" />
                <el-table-column label="盘点仓库" align="center" prop="warehouseName" />
                <el-table-column label="计划开始" align="center" prop="planStartTime" />
                <el-table-column label="计划结束" align="center" prop="planEndTime" />
                <el-table-column label="实际开始" align="center" prop="startTime" />
                <el-table-column label="实际结束" align="center" prop="endTime" />
                <el-table-column label="盘点负责人" align="center" prop="personInCharge" />
                <el-table-column label="审核人" align="center" prop="approveName" />
                <el-table-column label="备注" align="center" prop="remark" />
            </el-table>
            <pagination
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
            />
        </div>
    </div>
</template>

<script>
import { stocktakingList } from "@/api/system/stocktaking/stocktaking"
export default {
    name: "list",
    data() {
        return {
            // 遮罩层
            loading: true,
            // 总条数
            total: 0,
            // 列表数据
            list: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10
            }
        }
    },
    created() {
        this.getList()
    },
    methods: {
        // 获取列表
        getList() {
            this.loading = true
            stocktakingList(this.addDateRange(this.queryParams)).then(res => {
                this.list = res.rows
                this.total = res.total
                this.loading = false
            })
        },
        // 新建
        add(){
            this.$router.push({path:"/warehouseManagement/warehouse/stocktaking/add"})
        },
        // 查看
        handleView(row) {
            this.$router.push({path:"/warehouseManagement/warehouse/stocktaking/detail", query:{ id: row.id }})
        }
    }
}
</script>